#-*-coding:utf-8 -*-
# 众生平等，2019猪年大吉
# spark连接MySQL
from pyspark import SparkConf,SparkContext
from pyspark.sql import SQLContext,HiveContext
from pyspark import SparkContext,SQLContext
from pyspark.sql import SQLContext

sc = SparkContext("local","LDASample")
sqlContext=SQLContext(sc)
jdbcDf=sqlContext.read.format("jdbc").options(url="jdbc:mysql://localhost:3306/cms",driver="com.mysql.jdbc.Driver",dbtable="(SELECT * FROM province) province",user="root",password="root").load()
#print(jdbcDf.select('*').show(2))

jdbcDf.write.save("E:\\test\\out\\saveAsCsv\\py.csv",format='csv')

